@echo off
start cmd /c
chcp 65001
echo "--------------------------------"
echo hello myfriend~ nice to meet you!
echo "--------------------------------"

if not exist AutoCode goto cloneAndStart
goto pullAndStart

:cloneAndStart
git clone https://gitee.com/jack_jeffrey/AutoCode.git
cd AutoCode
goto cleanpackage

:pullAndStart
cd AutoCode
if not exist .git git init
git pull
goto cleanpackage

:cleanpackage
call mvn -Dmaven.test.skip=true clean package
if errorlevel 0 goto startJar
goto cleanpackage

:startJar
echo AutoCode Background Service is starting...
start /min "AutoCode Background Service" java -jar ./target/autocode-1.0.0-SNAPSHOT.jar
echo "------------------------------"
goto startweb

:startweb
cd ./src/main/resources/autocodeweb
goto runInstall

:runInstall
if not exist node_modules call npm install && goto runbuild
goto runbuild

:runbuild
if not exist dist call npm run build && goto runweb
goto runweb

:runweb
echo AutoCode Frontdesk Service is starting...
start /min "AutoCode Frontdesk Service" npm run dev
goto end

:end
echo good bye~
